const mysql = require('mysql');

exports.base = (sql,data,callback) => {
    //创建数据库连接
    const connection = mysql.createConnection({
        host:'182.61.145.76',
        port:'3306',
        user:'root',
        password:'mysql',
        database:'travel_website'
    })
    //执行连接操作
    connection.connect();
    //操作数据库
    connection.query(sql,data,function(error,results,fields){
        if(error) throw error;
        callback(results);
    })
    //关闭数据库
    connection.end()
}